package com.example.tingsugar.mapper;

import com.example.tingsugar.bean.TrafficBean;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TrafficMapper {
    @Select("SELECT\n" +
        "    ch,\n" +
        "    uv_ct,\n" +
        "    sv_ct,\n" +
        "    pv_ct / sv_ct AS pv_per_sv,\n" +
        "    dur_sum / sv_ct AS duration_per_sv\n" +
        "FROM\n" +
        "(\n" +
        "    SELECT\n" +
        "        ch,\n" +
        "        sum(pv_ct) AS pv_ct,\n" +
        "        sum(uv_ct) AS uv_ct,\n" +
        "        sum(sv_ct) AS sv_ct,\n" +
        "        sum(dur_sum) AS dur_sum\n" +
        "    FROM dws_traffic_ch_page_view_window\n" +
        "    WHERE toYYYYMMDD(stt) = #{date}\n" +
        "    GROUP BY ch\n" +
        ")")
    List<TrafficBean> traffic(Integer date);
}
